import type { AxiosResponse } from 'axios'
import request from '@/utils/request'
const serviceName = import.meta.env.VITE_APP_SREVICE_NAME_CITY_MANAGEMENT
const AUTH_SERVICE_NAME = import.meta.env.VITE_APP_SREVICE_NAME_AUTH
/**
 *  登录
 * @param data
 * @returns
 */
export function login(params: RecordType): Promise<AxiosResponse<any>> {
  return request({
    url: AUTH_SERVICE_NAME + '/login',
    method: 'get',
    params
  })
}

/**
 * 退出
 * @returns
 */
export function logout(): IApiResponse {
  return request({
    url: AUTH_SERVICE_NAME + '/logout',
    method: 'get'
  })
}

/**
 * user info
 * @returns
 */
export function info(): Promise<AxiosResponse<any>> {
  return request({
    url: `${serviceName}/sys/user/info`,
    method: 'get'
  })
}

/**
 * 根据code获取token
 * @returns
 */
export function changeToken(params: RecordType): Promise<AxiosResponse<any>> {
  return request({
    url: `${serviceName}/changeToken`,
    method: 'get',
    params: {
      code: params
    }
  })
}
